package cn.tedu.forum.user.webapi.controller;

import cn.tedu.forum.commons.response.JsonResponse;
import cn.tedu.forum.pojo.dto.RegisterDTO;
import cn.tedu.forum.pojo.vo.RegisterVO;
import cn.tedu.forum.user.service.IUserInfoService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@Api(tags = "用户注册")
public class RegisterController {
    @Autowired
    IUserInfoService userInfoService;

    @PostMapping("/register")
    @ApiOperation("用户注册")
    //@ApiOperationSupport(order = 10)
    public JsonResponse<RegisterVO> register(@Valid RegisterDTO registerDTO) {
        Long id = userInfoService.register(registerDTO);
        return JsonResponse.ok(new RegisterVO().setId(id));
    }

}
